﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ArmyBodger.UI {
    /// <summary>
    /// Draws a Fancy gradient header
    /// </summary>
    public partial class HeaderPanel : UserControl {
        /// <summary>
        /// Constructor
        /// </summary>
        public HeaderPanel() {
            InitializeComponent();
            this.Title = "No Entry";
        }
        /// <summary>
        /// Gradient from color
        /// </summary>
        protected Color from = Color.AliceBlue;
        public Color From {
            get {
                return this.from;
            }
            set {
                this.from = value;
                this.Refresh();
            }
        }
        /// <summary>
        /// Gradient to color
        /// </summary>
        protected Color to = Color.White;
        public Color To {
            get {
                return this.to;
            }
            set {
                this.to = value;
                this.Refresh();
            }
        }
        /// <summary>
        /// Header title
        /// </summary>
        protected string title = null;
        public string Title {
            get {
                return this.title;
            }
            set {
                this.title = value;
                this.Refresh();
            }
        }
        /// <summary>
        /// Overriden onpaint
        /// </summary>
        /// <param name="e">PaintEventArgs</param>
        protected override void OnPaint(PaintEventArgs e) {
            e.Graphics.Clear(this.BackColor);
            LinearGradientBrush lgb = new LinearGradientBrush(
                this.ClientRectangle,
                this.from,
                this.to,
                90
                );
            e.Graphics.FillRectangle(lgb, this.ClientRectangle);
            e.Graphics.DrawString(
                this.title,
                this.Font,
                new SolidBrush(this.ForeColor),
                2,
                this.Height / 2 - ((e.Graphics.MeasureString(this.title, this.Font).Height) / 2)
                );
        }
    }
}
